// 路由-相关模块
import Vue from 'vue'
import VueRouter from 'vue-router'
// 路由配置views
import Layout from '@/views/Layout'
import Search from '@/views/Search'
import Play from '@/views/Play'
import Home from '@/views/Home'

Vue.use(VueRouter)
const routes = [
    {
        path:'/',
        redirect:'/layout'
    },
    {
        path:'/layout',
        component:Layout,
        redirect:'/layout/home',
        // 二级路由嵌套
        children: [
            {
                path:'home',
                component:Home,
                // meta是保存路由对象额外信息得地方
                meta: {
                    title:"首页"
                }
            },
            {
                path:'search',
                component:Search,
                meta: {
                    title:"搜索"
                }
            }
        ]
    },
    {
        path:'/play',
        component:Play
    }
]
// 生成路由对象
const router = new VueRouter({
    routes
})
// 把生成好的路由对象向外导出
export default router